# Maintainer: Antonio Rojas <arojas@archlinux.org>
# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Andrea Scarpino <andrea@archlinux.org>

pkgname=qt6-wayland
_qtver=6.6.0
pkgver=${_qtver/-/}
pkgrel=2
arch=(loong64 x86_64)
url='https://www.qt.io'
license=(GPL3 LGPL3 FDL custom)
pkgdesc='Provides APIs for Wayland'
depends=(gcc-libs
         glibc
         libglvnd
         libxkbcommon
         qt6-base
         qt6-declarative
         wayland)
makedepends=(cmake
             ninja)
groups=(qt6)
_pkgfn=${pkgname/6-/}-everywhere-src-$_qtver
source=(https://download.qt.io/official_releases/qt/${pkgver%.*}/$_qtver/submodules/$_pkgfn.tar.xz
        qtbug-119110.patch::https://code.qt.io/cgit/qt/qtwayland.git/patch/?id=aae65c88
        qtbug-118650.patch::https://code.qt.io/cgit/qt/qtwayland.git/patch/?id=18f942f3)
sha256sums=('30c3d82d85d050c83370710a26d12c802199c51eba5c2726e9d6243edd03b7e8'
            'c0d92d9b3248321543b1ed99a2d894acafe7a13ef7f0ea64198fd11b41dea843'
            '1417909d41eec4a406a9bbbef713ed18d089a3710ee74931e07b9c0bbaea9726')

prepare() {
# Backport some fixes
  patch -d $_pkgfn -p1 < qtbug-119110.patch
  patch -d $_pkgfn -p1 < qtbug-118650.patch
}

build() {
  cmake -B build -S $_pkgfn -G Ninja \
    -DCMAKE_MESSAGE_LOG_LEVEL=STATUS
  cmake --build build
}

package() {
  DESTDIR="$pkgdir" cmake --install build

  install -d "$pkgdir"/usr/share/licenses
  ln -s /usr/share/licenses/qt6-base "$pkgdir"/usr/share/licenses/$pkgname
}
